package fanxing.demo04;

/**
 * @author Mr.ma
 * @since 2022/10/25 15:07
 *
 * 测试接口泛型，接口泛型在定义后，该接口的实现类大致有两种情况：
 *      1、同接口一样使用继续使用泛型，相当于Object
 *      2、给接口的泛型指定具体的数据类型
 **/
public class Test04 {
    public static void main(String[] args) {
        Car fuTe = new FuTe();
        fuTe.speed(178);
        fuTe.speed("时速每小时178KM");
        Car benTian = new BenTian();
        benTian.speed("每小时150KM");
    }
}

class FuTe<T> implements Car<T>{
    @Override
    public void speed(T t){
        System.out.println("t = " + t);
    }
}

class BenTian implements Car<String>{
    @Override
    public void speed(String s) {
        System.out.println("s = " + s);
    }
}

interface Car<T>{
    void speed(T t);
}